{include file="public/header" /}
</head>
<body>
<div class="wrap js-check-wrap">
    <ul class="nav nav-tabs">
        <li><a href="{:url('UserCenter/index')}">用户列表</a></li>
    </ul>
    <form method="post" class="form-horizontal js-ajax-form margin-top-20">
        <table class="table table-bordered">
            <tr>
                <th width="150">ID</th>
                <td>
                    {$info.user_id}
                </td>
            </tr>
            <tr>
                <th>手机号</th>
                <td>
                    {empty name="$info['user_phone']"}
                        未绑定手机号
                    {else /}
                        {$info.user_phone}
                    {/empty}
                </td>
            </tr>
            <tr>
                <th>邮箱</th>
                <td>
                    {empty name="$info['user_email']"}
                        未绑定邮箱
                    {else /}
                        {$info.user_email}
                    {/empty}
                </td>
            </tr>
            <tr>
                <th>会员类型<span class="form-required">*</span></th>
                <td>
                    <select class="form-control" name="userLevel" style="width: 200px;">
                        <option value='0' {if condition="$info['user_level'] eq '0'"}selected="selected" {/if} >普通会员</option>
                        <option value='1' {if condition="$info['user_level'] eq '1'"}selected="selected" {/if} >vip会员</option>
                    </select>
                </td>
            </tr>
            <tr>
                <th></th>
                <td>
                    <div class="col-sm-offset-2 col-sm-10">
                        <input type="hidden" name="id" value="{$info.user_id}" />
                        <input type="hidden" name="action" value="{$params['action']}" />
                        <button type="submit" class="btn btn-primary js-ajax-submit">提交</button>
                        <a class="btn btn-default" href="{:url('userCenter/index')}">返回</a>
                    </div>
                </td>
            </tr>
        </table>
    </form>
</div>
<script type="text/javascript" src="{$static}js/layer/layer.js"></script>
<script type="text/javascript">
    $(function () {
        $(".js-ajax-submit").click(function () {
            $.ajax({
                url: "{:url('userCenter/operateAjax')}",
                type: "POST",
                data: $(".js-ajax-form").serialize(),
                dataType: 'json',
                async: false,
                success: function (res) {
                    if(res.errorCode === 200){
                        layer.confirm(res.message, {
                            btn: ['确定']
                        }, function () {
                             window.location.href = "{:url('userCenter/index')}";
                        });
                    }else{
                        layer.alert(res.message, {
                            title: '提示',
                            icon: 2
                        });
                    }
                }
            });
            return false;
        });
    });
</script>
</body>
</html>
